package net.searchdata.pre;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

public class Entry28 {
	class Stack<E> {
		private List<E> list = new ArrayList<E>();

		public void push(E e) {
			list.add(e);
		}

		public E pop() {
			return list.remove(list.size() - 1);
		}

		public boolean isEmpty() {
			return list.isEmpty();
		}
	}

	@Test
	public void stackSimpleTest() {
		Stack<Integer> intStack = new Stack<Integer>();

		intStack.push(1);
		intStack.push(2);
		intStack.push(3);

		assertThat(intStack.pop(), is(3));
		assertThat(intStack.pop(), is(2));
		assertThat(intStack.pop(), is(1));
	}
}